﻿using Model;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using 纺织贸易管理系统;

namespace BLL
{
  public   class 当年进仓报表
    {
        public static DataTable CreateReport(DateTime date )
        {
            return Connect.CreatConnect().Query($"select MONTH(rq) as '月份', sum(TotalMishu) as '米数' from danjutable where year(rq)={date.Year } and djlx='{DanjuLeiXing.入库单}' group by month(rq) order by 月份");
            //DataTable resdt = new DataTable();
            //resdt.Columns.Add("日期", typeof(DateTime));
            //resdt.Columns.Add("米数", typeof(decimal));
            //for (int i = 0; i < 12; i++)
            //{
            //    resdt.Rows.Add();
            //    resdt.Rows[i]["日期"] = date.Date.AddMonths(i);
            //    var res = dt.Where(x => x.rq >= date.AddMonths(i) && x.rq <= date.AddMonths(i + 1).AddDays(-1)).ToList();
            //    resdt.Rows[i]["米数"] = res.Count > 0 ? res.Sum(x => x.TotalMishu) : 0;
            //}
            //return resdt;
        }
        public static DataTable CreateCustomerReport(DateTime date)
        {
            return Connect.CreatConnect().Query($"select ksmc,SUM(TotalMishu) as summishu  from DanjuTable  where year(rq)={date.Year }  and djlx ='生产入库单' group by ksmc ");
        }
        public static DataTable CreateCustomerDetailReport(DateTime date)
        {
            return Connect.CreatConnect().Query($"select ksmc,SUM(TotalMishu) as summishu  from DanjuTable  where year(rq)={date.Year } and Month(rq)={date.Month } and djlx ='生产入库单' group by ksmc ");
        }
    }
}
